<template>
  <div>
    <van-field v-model="form.username" label="用户名"></van-field>
    <van-field v-model="form.password" label="密码"></van-field>
    <van-button round @click="login">登录</van-button>
  </div>
</template>

<script>
export default {
  name: "alogin",
  data() {
    return {
      form: {}
    }
  },
  methods: {
    login() {
      this.$axios.post('/info/login', this.form)
        .then(res => {
          if (res.data.code == 200) {
            alert('登录成功')
            localStorage.setItem('userid', res.data.userid)
            localStorage.setItem('username', res.data.username)
            localStorage.setItem('sign', res.data.sign)
            this.$router.push('/ainfo')
          } else {
            alert(res.data.mes)
          }
        })
    }
  }
}
</script>

<style scoped>

</style>
